home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Includes / UClipboardMgr.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  5.7 KB  |  156 lines  |  [TEXT/MPS ]

  1. // UClipboardMgr.h
  2. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #ifndef __UCLIPBOARDMGR__
  5. #define __UCLIPBOARDMGR__
  6.  
  7. // MacApp
  8.  
  9. #ifndef __UBEHAVIOR__
  10. #include "UBehavior.h"
  11. #endif
  12.  
  13. // Toolbox
  14.  
  15. #ifndef __SCRAP__
  16. #include <Scrap.h>
  17. #endif
  18.  
  19. //----------------------------------------------------------------------------------------
  20. // Forward and external class declarations. 
  21. //----------------------------------------------------------------------------------------
  22.  
  23. class TCommandHandler;
  24. class TView;
  25. class TWindow;
  26.  
  27.  
  28. //----------------------------------------------------------------------------------------
  29. // TClipboardMgr: This object is responsible for interaction with the scrap manager.
  30. //----------------------------------------------------------------------------------------
  31.  
  32. const IDType kClipboardManager = 'clip'; // The behavior identifier 
  33.  
  34. class TClipboardMgr : public TBehavior
  35. {
  36.     MA_DECLARE_CLASS;
  37.     
  38. public:
  39.     //------------------------------------------------------------------------------------
  40.     // Initialize, I<Method>.
  41.     //------------------------------------------------------------------------------------
  42.  
  43.     TClipboardMgr();
  44.         // Constructor
  45.     virtual ~TClipboardMgr();
  46.         // Destructor
  47.         
  48.     void IClipboardMgr();
  49.     
  50.     
  51.     //------------------------------------------------------------------------------------
  52.     // Rest of methods.
  53.     //------------------------------------------------------------------------------------
  54.  
  55.     virtual void Close();
  56.  
  57.     virtual void Launch();
  58.  
  59.     virtual long GetDataToPaste(Handle aDataHandle, ResType& dataType);
  60.         // Returns the number of bytes in the paste data. Will signal Failure if it gets
  61.         // an error.
  62.  
  63.     virtual TWindow* MakeClipboardWindow();
  64.         // Called by to make the clipboard window. ClipView is the view to be initially
  65.         // installed in the clipboard--it is fClipOrphanage.
  66.  
  67.     virtual TView* MakeViewForAlienClipboard();
  68.         // Calls the application's MakeViewForAlienClipboard.If it returns a view then
  69.         // that view is returned to our caller else it returns fClipOrphanage, which is
  70.         // capable of displaying scrap of type TEXT or PICT. Override this to create a
  71.         // view to handle other types of scrap data.
  72.  
  73.     virtual OSErr PutDeskScrapData(ResType aResType, Handle aDataHandle);
  74.         // Call this from your TCommand method 'WriteToDeskScrap' (for a Command which
  75.         // changes the Clipboard) to write out data to the actual Desk Scrap. The return
  76.         // code from the Scrap Manager is returned as the function value -- will be noErr
  77.         // unless something went wrong. This procedure leaves aDataHandle UNLOCKED. Rather
  78.         // than calling this, you can call the ToolBox routine PutScrap yourself
  79.  
  80.     virtual void AboutToLoseControl(Boolean convertClipboard);
  81.  
  82.     virtual void AbsorbScrapStuff();
  83.         // Called to retrieve the current InfoScrap record from low memory. This will be
  84.         // used to determine if the scrap has changed.
  85.  
  86.     virtual void CheckDeskScrap();
  87.         // Checks to see if the desk scrap has changed by calling AbsorbScrapStuff and
  88.         // comparing the current scrap change count with the previous change count. If the
  89.         // scrap has changed, then the current clipboard becomes the undo clipboard and
  90.         // ReadFromDeskScrap is called to read in the new desk scrap.
  91.  
  92.     virtual void CanPaste(ResType aClipType);
  93.         // Call this in your SetUpMenus code to register an ability to paste a particular
  94.         // type of Clipboard data
  95.  
  96.     virtual void DoSetupMenus();
  97.         // Handles the show/hide clipboard command and enabling of paste
  98.  
  99.     virtual void DoMenuCommand(CommandNumber aCommandNumber);
  100.         // Handles the show/hide clipboard command
  101.  
  102.     virtual void ReadFromDeskScrap();
  103.         // Called at launch and when the desk scrap changes. Calls
  104.         // MakeViewForAlienClipboard, then ClaimClipboard
  105.  
  106.     virtual void RegainControl(Boolean checkClipboard);
  107.         // Called when switching in or when leaving a desk accessory
  108.  
  109.     virtual void SetClipView(TView* clipView, TCommandHandler* itsContext);
  110.         // Installs the given view into the clipboard window.
  111.  
  112.     
  113.     //------------------------------------------------------------------------------------
  114.     // data members
  115.     //------------------------------------------------------------------------------------
  116. public:
  117.  
  118.     ScrapStuff fOldScrapStuff;                    // the last ScrapStuff record used in
  119.                                                 // tracking the scrap
  120.  
  121.     ScrapStuff fNewScrapStuff;                    // the current ScrapStuff record used in
  122.                                                 // tracking the scrap
  123.  
  124.     TView* fClipOrphanage;                        // A view to represent the Clipboard when
  125.                                                 // the application can't
  126.  
  127.     TView* fClipView;                            // The view currently installed in the
  128.                                                 // Clipboard
  129.  
  130.     TCommandHandler* fClipContext;                // The context of the command which created the 
  131.                                                 // current clipboard view.
  132.  
  133.     TWindow* fClipWindow;                        // The window holding the Clipboard
  134.                                                 // display
  135.  
  136.     ResType fPrefClipType;
  137.  
  138.     Boolean fGotClipType;                        // True if we can paste the data in the
  139.                                                 // clipboard
  140.  
  141.     Boolean fClipWrittenToDeskScrap;            // True if the clipboard view has been
  142.                                                 // written to the desk scrap
  143. };
  144.  
  145.  
  146. //----------------------------------------------------------------------------------------
  147. // Definitions for externally available variables and functions.
  148. //----------------------------------------------------------------------------------------
  149.  
  150. extern TClipboardMgr* gClipboardMgr;
  151.  
  152. extern void InitUClipboardMgr();
  153.     // called to initialize the clipboard manager
  154.  
  155. #endif // __UCLIPBOARDMGR__
  156.